<?php
HBase::using('Backend.Robot.*');
HBase::using('Backend.*');

class backend_modules_index extends HModule {
	public $page;
	public $data;
	
	function run() {		
		if (isset($_POST['tbxName'])) {
			// Process the add form post
			self::process();
		}
		else {			
			// Get the current table page
			if (!isset($_GET['page'])) $this->page = 1;
			else $this->page = HCommon::xss($_GET['page']);
			
			// get Paged Data
			$this->data = HModules::getPaged($this->page, PAGE_SIZE);
		}
	}
	
	// Process of the form add
	function process() {
		$name = $_POST['tbxName'];		
		if (HModuleRobot::generate($name))
			HUtil::alert("Add module successfully!");
		else 
			HUtil::alert("ERROR! Module Name exists");	
		HUtil::redirect(HCommon::navigateUrl('Modules'));		
	}
}

?>